#include <iostream>
#include "LinkedList.h"

using namespace std;

ListNode *createLinkedList(int arr[], int n)
{
  if (n == 0)
    return NULL;
  ListNode *head = new ListNode(arr[0]);
  ListNode *curNode = head;
  for (int i = 1; i < n; ++i)
  {
    curNode->next = new ListNode(arr[i]);
    curNode = curNode->next;
  }
  return head;
}

void printLinkedList(ListNode *head)
{
  ListNode *curNode = head;
  while (curNode != NULL)
  {
    cout << curNode->val << "->";
    curNode = curNode->next;
  }
  cout << "NULL" << endl;
  return;
}

void deleteLinkedList(ListNode *head)
{
  ListNode *curNode = head;
  while (curNode != NULL)
  {
    ListNode *delNode = curNode;
    curNode = curNode->next;
    delete delNode;
  }
  cout << "内存释放结束" << endl;
  return;
}